<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:a="attribute"
    xmlns:o="object"
    xmlns:c="collection"
>

  <xsl:output method="text" indent="yes" encoding="utf-8" version="1.0"/>


  <xsl:template match="/" >
    <xsl:for-each select="//c:Entities">
      <xsl:call-template name="Entitie"></xsl:call-template>
    </xsl:for-each>
  </xsl:template>
  <xsl:template name="Entitie">
    namespace Model{
    <xsl:for-each select="o:Entity">
      <xsl:if test="count(a:Comment)>0">
      /// &lt;summary&gt;
      /// <xsl:value-of select="a:Comment"></xsl:value-of>
      /// &lt;/summary&gt;</xsl:if>
      [Serializable]
      public partial class <xsl:value-of select="a:Name"/>{
      <xsl:for-each select="c:Attributes/o:EntityAttribute"><xsl:if test="count(a:Comment)>0">
        /// &lt;summary&gt;
        /// <xsl:value-of select="a:Comment"></xsl:value-of>
        /// &lt;/summary&gt;</xsl:if>
        public <xsl:choose>
          <xsl:when test="a:DataType='Identity'">string </xsl:when>
		      <xsl:when test="a:DataType='Unique'">string </xsl:when>
          <xsl:when test="a:DataType='I'">int </xsl:when>
          <xsl:when test="a:DataType='F'">float </xsl:when>
          <xsl:when test="a:DataType='BL'">bool </xsl:when>
          <xsl:when test="a:DataType='D'">DateTime </xsl:when>
            <xsl:when test="a:DataType='DT'">DateTime </xsl:when>
          <xsl:when test="contains(a:DataType,'TXT')">string </xsl:when>
          <xsl:when test="contains(a:DataType,'Text')">string </xsl:when>
        </xsl:choose><xsl:value-of select="a:Name"/>{get;set;}
      </xsl:for-each>
      }
    </xsl:for-each>
    }
  </xsl:template>
</xsl:stylesheet>